package 字符流;

import java.io.*;

/*
* BufferedWriter(Writer out) 字符缓冲输出流对象
* BufferedReader(Reader in) 字符缓冲输入流对象
* */
public class 字符缓冲流基本使用 {
    public static void main(String[] args) throws IOException {
        /*BufferedWriter(Writer out) 写数据*/
        BufferedWriter bw = new BufferedWriter(new FileWriter("D:\\111\\222.txt"));
        bw.write("hello\r\n");
        bw.write("world\r\n");
        bw.close();
        /*BufferedReader(Reader in) 读数据*/
        BufferedReader br = new BufferedReader(new FileReader("D:\\111\\222.txt"));
        /*一次读取一个字符数据*/
//        int ch;
//        while ((ch=br.read())!=-1){
//            System.out.println((char) ch);
//        }
        /*一次读取一个字符数组数据*/
        char[] chs = new char[1024];
        int len;
        while ((len=br.read(chs))!=-1){
            System.out.println(new String(chs,0,len));
        }
        br.close();
    }
}